<% content_for :title do %>
  <header class="profile__header">
    <div class="profile__header__name-wrap">
      <div id="avatar-frame">
        <%= 
          image_tag(
            @user.gravatar_url(size: 300, secure: request.ssl?).html_safe,
            id: "profile_gravatar",
            width: 300,
            height: 300,
            class: 'profile__header__avatar'
          )
        %>
      </div>

      <h1 id="profile-name" class="profile__header__name t-display">
        <%= 
          link_to(
            @user.display_handle, profile_path(@user.display_id),
            class: "t-link--black"
          )
        %>
      </h1>

      <% unless @user.hide_email %>
        <p id="profile-email">
          <%= 
            mail_to(
              @user.email,
              "Email Me",
              encode: "hex",
              class: "profile__header__attribute t-link--black",
              'data-icon' => '✉'
            )
          %>
        </p>
      <% end %>

      <% if @user.twitter_username.present? %>
        <%=
          image_tag(
            "/images/twitter_icon.png",
            alt: 'Twitter icon',
            class: 'profile__header__icon'
          )
        %>

        <%=
          link_to(
            twitter_username(@user),
            twitter_url(@user),
            class: "profile__header__attribute t-link--black"
          )
        %>
      <% end %>

      <% if @user == current_user %>
        <div id="downloads-ego">
          <%=
            link_to(
              "Edit Profile",
              edit_profile_path,
              id: "edit-profile",
              class: "profile__header__attribute t-link--black"
            )
          %>
        </div>
      <% end %>
    </div>

    <div class="profile__downloads-wrap">
      <h4 class="gem__downloads__heading t-text--s">
        <%= t('stats.index.total_gems') %>
      </h4>

      <h2 id="profile-gems-count" class="gem__downloads">
        <%= @user.total_rubygems_count.to_s %>
      </h2>

      <h4 id="downloads" class="gem__downloads__heading t-text--s">
        <%= t('stats.index.total_downloads') %>
      </h4>

      <h2 id="downloads_count" class="gem__downloads">
        <%= number_with_delimiter(@user.total_downloads_count) %>
      </h2>
    </div>
  </header>
<% end %>

<div id="profile">
  <div class="profile-list">
    <ul>
      <%=
        render(
          partial: 'rubygem',
          collection: @rubygems + @extra_rubygems,
          locals: {graph: false}
        )
      %>
    </ul>
  </div>
</div>
